package com.admin.system.interceptor;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfigurer implements WebMvcConfigurer {
	@Resource
	OperationLogInterceptor operationLogInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		List<String> paths = new ArrayList<>();
		//静态文件的访问不记录日志
		paths.add("/external/**");
		paths.add("/inward/**");
		paths.add("/img/**");
		paths.add("/error");
		//日志记录在接口日志
		paths.add("/gateWay");
		registry.addInterceptor(operationLogInterceptor).addPathPatterns("/**").excludePathPatterns(paths);
	}
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		//registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
	}
}